﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Masters/Basic.Master" AutoEventWireup="true" CodeBehind="BottleSupplierList.aspx.cs" Inherits="PMS.UI.BD.BottleSupplierList" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script type="text/javascript">
        $(function () {
            var rowData;
            var height = $("#divTotal").height();
            var master = $("#master").height();
            var content = parseFloat(height) - parseFloat(master) - 30;
            $("#tbList").css("height", content);
        });
    </script>
    <script type="text/javascript">
        $(function () {
            $("#tbList").datagrid({
                url: '/Logic/BD/BottleSupplierAjax.aspx?method=GetBottleSupplierList',
                loadMsg: '数据加载中请稍后……',
                pagination: true,
                rownumbers: true,
                idField: "ID",
                lines: true,
                // fitColumns:true,
                frozenColumns: [[{
                    field: 'ck', checkbox: true, width: 30
                },
                    {
                        field: 'ID', title: 'ID', width: 50, align: "center"
                    },
                    {
                        field: 'BottleSupplier', title: '生产厂家名', sortable: true, width: 100, align: "center", editor: {
                            type: "validatebox",
                            options: {
                                required: true
                            }
                        }
                    },
                {
                    field: 'MadeCode', title: '制造代码', sortable: true, width: 100, align: "center", editor: {
                        type: "validatebox",
                        options: {
                        }
                    }
                },
                {
                    field: 'FillPerson', title: '维护人', sortable: true, width: 100, align: "center"
                    
                },
                 {
                     field: 'FillDate', title: '维护时间', sortable: true, width: 100, align: "center"

                 },
                        {
                            field: 'Note', title: '备注', sortable: false, width: 200, align: "center", editor: {
                                type: "validatebox",
                                options: {
                                    validType: ['length[0,250]']
                                }
                            }
                        }
                ]],
                singleSelect: true,
                pageSize: 20,
                queryParams: com.serializeSearchArray("form1"),
                pageList: [20, 50, 100],
                striped: true,
                onAfterEdit: function (rowIndex, rowData, changes) {
                    //rowIndex，该结束行的索引
                    //console.info(row);
                    //   console.log(rowData);
                    if (editAction == "edit") {
                        com.ajax({
                            url: "/Logic/BD/BottleSupplierAjax.aspx?method=EditBottleSupplier",
                            data: rowData,
                            success: function (data) {
                                com.message(data.state, data.msg, function () { $("#tbList").datagrid("reload"); });
                            }
                        });
                    } else if (editAction == "add") {
                        com.ajax({
                            url: "/Logic/BD/BottleSupplierAjax.aspx?method=AddBottleSupplier",
                            data: rowData,
                            success: function (data) {
                                com.message(data.state, data.msg, function () { $("#tbList").datagrid("reload"); });
                            }
                        });
                    }
                    editRow = undefined;
                },
                onCancelEdit: function (rowIndex, rowData) {
                    $("#tbList").datagrid("rejectChanges");
                }
            });
        })


    </script>
    <script>
        editRow = undefined;
        editAction = undefined;
        function funcSearch() {
            var para = com.serializeSearchArray("form1");
            $("#tbList").datagrid("load", para);

        }
        function funcAdd() {
            //添加时先判断是否有开启编辑的行，如果有则把开户编辑的那行结束编辑
            if (editRow != undefined) {

            }
            //添加时如果没有正在编辑的行，则在datagrid的第一行插入一行
            if (editRow == undefined) {
                $("#tbList").datagrid("insertRow", {
                    index: 0, // index start with 0
                    row: {
                        GBID: 0
                    }
                });
                //将新插入的那一行开户编辑状态
                $("#tbList").datagrid("beginEdit", 0);
                //给当前编辑的行赋值
                editRow = 0;
                editAction = "add";
            }
        }
        function funcEdit() {
            var row = $('#tbList').datagrid('getSelected');

            if (row) {
                if (editRow != undefined) {
                }
                else {
                    var index = $("#tbList").datagrid('getRowIndex', row);
                    //  console.log(index);
                    $("#tbList").datagrid('beginEdit', index);
                    editAction = "edit";
                    editRow = index;
                    rowData = $("#tbList").datagrid("getSelected");
                }
            }
            else {
                com.message("information", "请选中一行");
            }
        }
        function funcRemove() {
            $.messager.confirm('确认对话框', '您确定删除该行吗？', function (r) {
                if (r) {
                    var rowData = $("#tbList").datagrid("getSelected");
                    if (rowData) {
                        com.ajax({
                            url: '/Logic/BD/BottleSupplierAjax.aspx?method=DelBottleSupplier',
                            data: { Id: rowData.ID },
                            success: function (data) {
                                com.message(data.state, data.msg, function () { $("#tbList").datagrid("reload"); $('#tbList').datagrid('clearSelections'); })
                            }
                        });
                    }
                }
            });
        }
        function funcSave() {
            $('#tbList').datagrid('endEdit', editRow);
        }
        function funcCancel() {
            $('#tbList').datagrid("cancelEdit", editRow);
            editRow = undefined;
            editAction = undefined;
        }
        function funcReload() {
            $("#form1").form("reset");
            var para = com.serializeSearchArray("form1");
            $("#tbList").datagrid("load", para);
            funcCancel()
        }

    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div id="divTotal" style="height: 100%; width: 100%">
        <div id="master" class="container_12" style="height: auto">
            <form id="form1">
                <div class="grid_1 sealbl" style="text-align: right;">
                    生产厂家:
                </div>
                <div class="grid_2 seaval" style="text-align: left;">
                    <input type="text" id="BottleSupplier" name="BottleSupplier" data-cp="co" />
                </div>
                <div class="grid_1 sealbl" style="text-align: right;">
                    制造代码:
                </div>
                <div class="grid_2 seaval" style="text-align: left;">
                    <input type="text" id="MadeCode" name="MadeCode" data-cp="co" />
                </div>

            </form>
        </div>
        <table id="tbList" title="生产厂家表" style="width: 100%">
        </table>
    </div>
</asp:Content>
